<?php
namespace Hwpush;

use Hwpush\message\BatchMessageBody;
use Hwpush\message\NoticeBody;

include __DIR__ . 'autoload.php';
class Push
{
    protected $appId;
    protected $appSecret;

    public function setUp()
    {
        $this->appId = '100028209';
        $this->appSecret = '8a05e56939e40a8b7c45a3dea8698716';
        //	com.gcs.xiaopei
    }

    public function testApi()
    {


        $deviceTokenList = array('');
        $_message = 'hello world';
        $cacheMode = 1;
        $msgType = 1;
        $expire_time = time()+100000; // 2017/08/15 20:00:00

        $hwpush = new Api($this->appId, $this->appSecret);
        $message = new BatchMessageBody($deviceTokenList, $_message, $cacheMode, $msgType, $expire_time);

        return $hwpush->BatchSend($message);

    }

    public function testSendNotice($token='')
    {
        $message = new NoticeBody();
        $message->push_type = 1;
        $message->tokens = '0869963021290845300000815000CN01';
        $message->android = '{"notification_title":"共享现金","notification_content":"收到请和汪栋说一声","doings":1}';

        $hwpush = new Api($this->appId, $this->appSecret);
        $res = json_decode($hwpush->SendNotice($message), true);
        return $res;

    }

}
